package com.xpchenfrank.test.fanxing;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author xpchen
 * @time 2018/5/31 15:02
 * @Description
 * @copyright Wuxi Yazuo ,Ltd.copyright 2015-2025
 */
public class FanxingClass {

    public static void main(String[] args) {

        Map map = new HashMap();
        map.put("msg", "yes");//map里面装有yes
        map.put("msg2", "no");//map里面装有yes
        map.put("msg3", "no");//map里面装有yes
        System.out.println(JSONUtils.toJSONString(map));

        String test = "辣子鸡丁15元";
        System.out.println("string length is " + test.length());
        //System.out.println("substring is " + test.substring(4,8));

        String blankString = " ";
        if(StringUtils.isNotBlank(blankString)) {
             System.out.println("判断到不是空");
        }

        String tempStr = "123我爱你";
        String result = tempStr.substring(3, 6);
        System.out.println("result is " + result);

        result = tempStr.substring(0, tempStr.length());
        System.out.println("result is " + result);

        String fullStr = "巧手烧鳝段.....58元";
        String removeString = ".....";

        int chineseIndex = 4;
        int priceIndex = 10;

        if(chineseIndex+1 <= fullStr.length()) {
            String firstStr = fullStr.substring(0, chineseIndex+1);
            String lastStr = fullStr.substring(priceIndex, fullStr.length());
            System.out.println("result is " + firstStr + lastStr);
        }

        Map<String, String> testMap = Maps.newHashMap();
        testMap.put("元", "元");

        System.out.println("test Map 元 is " + testMap.get("元"));



//        try {
//            String testStr = null;
//            testStr.length();
//        } catch (Exception e) {
//
//            System.out.println("message is " + e.getMessage());
//            System.out.println("cause is " + e.getCause());
//
//            StackTraceElement[] stackTraceElements = e.getStackTrace();
//            if(stackTraceElements != null) {
//                for (StackTraceElement stackTraceElement : stackTraceElements) {
//                    System.out.println("stackTraceElement is " + stackTraceElement);
//                }
//            }
//
//            ByteArrayOutputStream baos = new ByteArrayOutputStream();
//            e.printStackTrace(new PrintStream(baos));
//            String exception = baos.toString();
//            System.out.println("baos:" + exception);
//
//
//            e.printStackTrace();
//        }


    }

}
